# Maintainer: Andreas Radke <andyrtr@archlinux.org>
# Contributor: Aaron Griffin <aaron@archlinux.org>

pkgname=lftp
pkgver=4.9.2
pkgrel=2
pkgdesc="Sophisticated command line based FTP client"
arch=('loong64' 'x86_64')
license=('GPL3')
depends=('glibc' 'gcc-libs' 'readline' 'gnutls' 'expat' 
         'zlib' 'libidn2' 'ncurses' 'sh' 'hicolor-icon-theme')
optdepends=('perl: needed for convert-netscape-cookies and verify-file')
url="https://lftp.yar.ru/"
backup=('etc/lftp.conf')
source=(https://lftp.yar.ru/ftp/${pkgname}-${pkgver}.tar.xz{,.asc}
        lftp-4.9.2-gnutls-peers2.patch )
sha256sums=('c517c4f4f9c39bd415d7313088a2b1e313b2d386867fe40b7692b83a20f0670d'
            'SKIP'
            '85577ef131c795936aca039d18ece7ff62fdb03905d37087e5d03d53c8409a94')
validpgpkeys=('C027FA3148652A5513036413A824BB69F2A99A18') # "Alexander V. Lukyanov <lav@yars.free.net>"

prepare() {
  cd "${pkgname}"-${pkgver}
  # Use gnutls_certificate_verify_peers2 to verify server - FS#80239
  patch -Np1 -i ../lftp-4.9.2-gnutls-peers2.patch
}

build() {
  cd "${pkgname}"-${pkgver}
  ./configure --prefix=/usr \
    --with-gnutls \
    --without-openssl \
    --without-included-regex \
    --disable-static
  make
}

package() {
  cd "${pkgname}"-${pkgver}
  make DESTDIR="${pkgdir}" install
  rm -rf "${pkgdir}"/usr/lib
}
